using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using MettleSystems.dashCommerce.Web.resources;
using SubSonic.Utilities;

namespace MettleSystems.dashCommerce.Web.admin.controls.sitesettings {
  public partial class footer : SiteSettingsControl {

    #region Constants

    private const string DEFAULT_FOOTER_COLOR = "#fff";

    #endregion

    #region Module Variables

    private string view = string.Empty;

    #endregion

    #region Page Events

    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
    protected void Page_Load(object sender, EventArgs e) {
      view = Utility.GetParameter("view");
      if(pnlSettings.Visible) {
        SetFooterSettingsProperties();
        if (!Page.IsPostBack) {
          txtFooterColor.Text = string.IsNullOrEmpty(SiteSettings.FooterColor) ? DEFAULT_FOOTER_COLOR : SiteSettings.FooterColor;
        }
      }
    }

    /// <summary>
    /// Handles the Click event of the btnSave control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
    protected void btnSave_Click(object sender, EventArgs e) {
      SiteSettings.FooterColor = txtFooterColor.Text.Trim();
      base.Save(SiteSettings);
    }

    #endregion

    #region Methods

    #region Private

    /// <summary>
    /// Sets the footer settings properties.
    /// </summary>
    private void SetFooterSettingsProperties() {
      this.Page.Title = WebUtility.GetText("titleSiteSettingsFooter");
      pnlSettings.GroupingText = WebUtility.GetText("pnlFooter");
      WebUtility.AddLabelText(lblFooterColor);
      WebUtility.AddButtonText(btnSave);
      WebUtility.AddHoverHelp(hlFooterHelp);
    }

    #endregion

    #endregion

  }
}